import tkinter
import regiest系统
from tkinter import *
win = tkinter.Tk()
win.title('This is a procedure of Mr.chen')
win.geometry('800x600')


def get_text(n):
    return n.get()

label_show = tkinter.Label(win,text='Welcome to 学生管理系统！',font=30)
label1 = tkinter.Label(master=win,text='请注册用户名：')
label2 = tkinter.Label(master=win,text='请注册密码：')



entry1 = tkinter.Entry(master=win)
entry2 = tkinter.Entry(master=win)

# 注册用户名
label_show.pack()
label1.place(x=20,y=40)
entry1.place(x=120,y=40)

# 注册密码
label2.place(x=20,y=80)
entry2.place(x=120,y=80)


# 确认注册并提示
def tishi():

    # 得到 str 并保存 MD5 到 file 中
    username = get_text(entry1)
    password = get_text(entry2)
    regiest系统.register(username, password)


    # 确认注册并提示
    jiazai_label = tkinter.Label(win, text='Loading  -------  Load the success ! ',font='楷体',fg='green')
    jiazai_label.place(x=20, y=140)

    # 登录布局

    # username登录
    label_username = tkinter.Label(win, text='请输入用户名登录：')
    label_username.place(x=60, y=170)

    entry_loading_username = tkinter.Entry(win)
    entry_loading_username.place(x=120, y=190)

    # password 登录
    label_password = tkinter.Label(win, text='请输入密码：')
    label_password.place(x=60, y=220)

    entry_loading_password = tkinter.Entry(win,show='*')
    entry_loading_password.place(x=120, y=240)



    def judge():

        # 登录，其转为MD5 ，并在文件中验证 是否正确
        loading_username = get_text(entry_loading_username)
        loading_password = get_text(entry_loading_password)
        res = regiest系统.login(loading_username, loading_password)
        # res 为登录结果
        label_tishi = tkinter.Label(win,text = res+' ~_~ ', font='楷体',fg='orange')
        label_tishi.place(x=220,y=300)


    button_load = tkinter.Button(win,text='确认登录',font='楷体',command=judge,bg = 'skyblue')
    button_load.place(x=220, y=260)


ture_regiest = tkinter.Button(win,text='确定注册！',font='楷体',command=tishi)
ture_regiest.place(x=220,y=100)



win.mainloop()